package com.chenglu.android.index.adapter;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.index.bean.TabTitleBean;

import java.util.List;

/**c
 * @author: lyj
 * @Created: by Copyright 2023/3/13 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：首页文字adapter数据
 */
public class HomeTabTitleAdapter extends BaseQuickAdapter<TabTitleBean.Data, BaseViewHolder> {

    private Context mContext ;
    public HomeTabTitleAdapter(@Nullable Context context, List<TabTitleBean.Data> data) {
        super(R.layout.item_home_tab_title, data);
        this.mContext = context;

    }



    @Override
    protected void convert(@NonNull BaseViewHolder helper, TabTitleBean.Data item) {


        if(item!=null){
//            LogUtils.e("picadapter中的数据"+item.toString());
            TextView textView = helper.getView(R.id.tv_tab_title);
            TextView textView2 = helper.getView(R.id.tv_tab_title2);
            textView.setText(item.getMenuName());
            textView2.setText(item.getDecriptions());

            if(helper.getAdapterPosition() == getThisPosition()){
                textView.setTextColor(mContext.getResources().getColor(R.color.home_new_color));
                textView2.setTextColor(mContext.getResources().getColor(R.color.white));
                textView2.setBackground(mContext.getResources().getDrawable(R.drawable.corners_homecolor_shape_press_8));
            }else {
                textView.setTextColor(mContext.getResources().getColor(R.color.all_black_text));
                textView2.setTextColor(mContext.getResources().getColor(R.color.color_f7f7f7));
                textView2.setBackground(mContext.getResources().getDrawable(R.drawable.corners_homecolor_shape_default_8));
            }

        }
    }


    private int  thisPosition = 0;

    public int getThisPosition() {
        return thisPosition;
    }

    public void setThisPosition(int thisPosition) {
        this.thisPosition = thisPosition;
        notifyDataSetChanged();
    }
}
